'''
Created on Nov 25, 2010

@author: philip
'''

from django.db import models
from django.utils.html import strip_tags

class Tip(models.Model):
    content = models.TextField()
    # pure textual version without any tags
    contentText = models.TextField()
    communityId = models.CharField(max_length=50)
    added = models.DateTimeField(auto_now_add=True)
    
    def save(self, *args, **kwargs):
        self.contentText = strip_tags(self.content)
        super(Tip, self).save(*args, **kwargs)
    
    @staticmethod
    def toJSON(i):
        return {"id":i.id,"content":i.content,"communityId":i.communityId}